home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Applications / FlyThrough 1.1.2 / src / Source / Vehicle Classes / CVehicleViewPane.h < prev   
Encoding:
Text File  |  1997-03-17  |  3.3 KB  |  131 lines  |  [TEXT/CWIE]

  1. //
  2. //    CVehicleViewPane.h
  3. //
  4. //    The view from the vehicle (a camera and lights) into a QD3D world.
  5. //
  6. //    By James Jennings
  7. //    Started July 9 1996
  8. //
  9.  
  10. #pragma once
  11.  
  12. #include "CQD3DPane.h"
  13. #include "CVehicle.h"
  14. #include "CObjectMaker.h"
  15.  
  16. const CommandT cmd_ViewFromFront    = 3001;
  17. const CommandT cmd_ViewFromBack        = 3002;
  18. const CommandT cmd_ViewFromLeft        = 3003;
  19. const CommandT cmd_ViewFromRight    = 3004;
  20. const CommandT cmd_ViewFromTop        = 3005;
  21. const CommandT cmd_ViewFromBottom    = 3006;
  22. const CommandT cmd_ViewFromCenter    = 3007;
  23. const CommandT cmd_LookAtCenter        = 3008;
  24. const CommandT cmd_StabilizeRoll    = 3010;
  25.  
  26. const CommandT cmd_BackgroundColor    = 1000;
  27.  
  28. // helper function (no longer used?)
  29. //Boolean KeyIsDown( Char16 inKeyCode );
  30.  
  31. class CAbstractLight : public CObjectMaker<TQ3LightObject> {
  32. public:
  33.     Boolean IsOn()
  34.     {
  35.         TQ3Status theStatus;
  36.         TQ3Boolean isOn;
  37.         theStatus = ::Q3Light_GetState(Get(), &isOn);
  38.         Assert_(theStatus==kQ3Success);
  39.         return isOn == kQ3True;
  40.     }
  41.     void    TurnOn(Boolean inOn)
  42.     {
  43.         TQ3Status theStatus;
  44.         theStatus = ::Q3Light_SetState(Get(), (TQ3Boolean)inOn);
  45.         Assert_(theStatus==kQ3Success);
  46.     }
  47. };
  48.  
  49. class CAmbientLight : public CAbstractLight {
  50. protected:
  51.     virtual void Make()
  52.     {
  53.         TQ3LightData data = {
  54.                 kQ3False,    // isOn
  55.                 0.2,        // brightness
  56.                 {1,1,1}        // color
  57.             };
  58.         mObject = ::Q3AmbientLight_New(&data);
  59.         Assert_(mObject != nil);
  60.     }
  61. };
  62.  
  63. class CFillLight : public CAbstractLight {
  64. protected:
  65.     virtual void Make()
  66.     {
  67.         TQ3DirectionalLightData data = {
  68.                 {
  69.                     kQ3False,    // isOn
  70.                     0.75,        // brightness
  71.                     {1,1,1}        // color
  72.                 },
  73.                 kQ3False,        // casts shadows
  74.                 {.5,-.5,-.7}        // direction
  75.             };
  76.         ::Q3Vector3D_Normalize( &data.direction, &data.direction );
  77.         mObject = ::Q3DirectionalLight_New(&data);
  78.         Assert_(mObject != nil);
  79.     }
  80. };
  81.  
  82. class CVehicleViewPane : public CQD3DPane, public LPeriodical, public LCommander {
  83. public:
  84.     enum { class_ID = 'VehV' };
  85.     static CVehicleViewPane * CreateFromStream( LStream *inStream );
  86.     static void Register()
  87.         { URegistrar::RegisterClass(class_ID, (ClassCreatorFunc) CreateFromStream); }
  88.     
  89.     CVehicleViewPane( LStream *inStream );
  90.     
  91.     virtual void        SetModel( TQ3GroupObject inGroup );
  92.     virtual void        SetCamera( TQ3CameraObject inCamera );
  93.     virtual void        SetLights( TQ3GroupObject inGroup );
  94.     virtual TQ3CameraObject        GetCamera(void);
  95.     virtual TQ3GroupObject        GetLights(void);
  96.     
  97.     virtual CVehicle *    GetVehicle() { return &mVehicle; }
  98.     
  99.         // Commander methods
  100.     virtual Boolean        ObeyCommand(
  101.                                 CommandT            inCommand,
  102.                                 void                *ioParam = nil);
  103.     virtual void        FindCommandStatus(
  104.                                 CommandT            inCommand,
  105.                                 Boolean                &outEnabled,
  106.                                 Boolean                &outUsesMark,
  107.                                 Char16                &outMark,
  108.                                 Str255                outName);
  109.     virtual void        DoBackgroundColor();
  110.     
  111. protected:
  112.     virtual void     ClickSelf(const SMouseDownEvent    &inMouseDown);
  113.     virtual void    SpendTime( const EventRecord &inMacEvent );
  114.     virtual void    AdjustCursorSelf( Point inPortPt, const EventRecord& inMacEvent );
  115.     
  116.     virtual Boolean    CheckAccelerationKeys( Boolean inDraw );
  117.  
  118.     virtual TQ3InterpolationStyle GetInterpolationStyle() 
  119.                         { return kQ3InterpolationStyleVertex; }
  120.     virtual TQ3BackfacingStyle GetBackfacingStyle() 
  121.                         { return kQ3BackfacingStyleFlip; }
  122.     
  123.     CFillLight        mExtraLight;
  124.     CAmbientLight    mExtraLight2;
  125.     
  126.     CVehicle    mVehicle;
  127.     TQ3Point3D    mCenter;
  128.     float        mSceneRadius;
  129.     Int32        mLastTime;
  130. };
  131.